package com.lzx.dormsys.controller;

import java.util.List;

import com.lzx.dormsys.core.AjaxResult;
import com.lzx.dormsys.core.controller.BaseController;
import com.lzx.dormsys.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lzx.dormsys.bean.RoomtypeBean;
import com.lzx.dormsys.service.IRoomtypeBeanService;

/**
 * roomtypeController
 *
 * @author ruoyi
 * @date 2021-09-09
 */
@RestController
@RequestMapping("/roomtypeAction")
public class RoomtypeBeanController extends BaseController
{
    @Autowired
    private IRoomtypeBeanService roomtypeBeanService;

    /**
     * 查询roomtype列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RoomtypeBean roomtypeBean)
    {
        startPage();
        List<RoomtypeBean> list = roomtypeBeanService.selectRoomtypeBeanList(roomtypeBean);
        return getDataTable(list);
    }

    /**
     * 获取roomtype详细信息
     */
    @GetMapping(value = "/{roomtypeId}")
    public AjaxResult getInfo(@PathVariable("roomtypeId") Long roomtypeId)
    {
        return AjaxResult.success(roomtypeBeanService.selectRoomtypeBeanById(roomtypeId));
    }

    /**
     * 新增roomtype
     */
    @PostMapping
    public AjaxResult add(@RequestBody RoomtypeBean roomtypeBean)
    {
        return toAjax(roomtypeBeanService.insertRoomtypeBean(roomtypeBean));
    }

    /**
     * 修改roomtype
     */
    @PutMapping
    public AjaxResult edit(@RequestBody RoomtypeBean roomtypeBean)
    {
        return toAjax(roomtypeBeanService.updateRoomtypeBean(roomtypeBean));
    }

    /**
     * 删除roomtype
     */
	@DeleteMapping("/{roomtypeIds}")
    public AjaxResult remove(@PathVariable Long[] roomtypeIds)
    {
        return toAjax(roomtypeBeanService.deleteRoomtypeBeanByIds(roomtypeIds));
    }
}
